package learn.ch1;

import java.util.Random;

/**
 * @Description todo
 * @Author yusj
 * @Date 2021/12/12
 * @Version 1.0
 */
public class Sv01 {
    //线程不安全，并发调用，会出现什么情况。count 是否按顺序增加。

    public void done(){
        StringBuilder count=new StringBuilder();
        for(int i=0;i<10;i++){
            count.append(i).append(",");
            System.out.println("name:"+Thread.currentThread().getName()+" count:"+count);
            try {
                Random r = new Random();
                Thread.sleep(r.nextInt(1000));
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
